﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IWMAG.Scripting.AST {
    public class VariableScopeTreeNode {
        public VariableScopeTreeNode Parent { get; private set; }
        public VariableScopeTreeNode(VariableScopeTreeNode parent = null) {
            this.Parent = parent;
            this.variableStorage = new Dictionary<string, object>();
        }

        Dictionary<string, object> variableStorage;

        public bool DoesVariableExist(string s) {
            var existsAtLevel = variableStorage.ContainsKey(s);
            if (existsAtLevel) {
                return true;
            }

            if (Parent == null) {
                return false;
            }

            return Parent.DoesVariableExist(s);
        }

    }
}